﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using mealplanner;
using NUnit.Framework;
using mealplanner.control;
using mealplanner.database;


namespace mealplannerUnitTest
{
    [TestFixture]
    class MenuUnitTesting
    {
        public delegate void fNadd_menu(ArrayList a);
        menu _menu;
        
        [SetUp]
        public void SetUp()
        {
            _menu = new menu();
        }
        //***
        
        
        [Test]
        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "There was an unhandled null")]
        public void add_menuTestFn()
        {
            //SetUp();
            ArrayList addMenuTest = new ArrayList();
            addMenuTest.Add("week1");
            addMenuTest.Add(null);
            addMenuTest.Add(null);
            fNadd_menu addmenu = _menu.add_menu;
            addmenu((addMenuTest));
        }


        //***
        [Test]
        public void checkStructureTestFnMenu1()
        {
            //SetUp();
            int returnAns = -1, actualreturnAns;
            ArrayList checkStructureTest = new ArrayList();
            checkStructureTest.Add("Day 1");
            checkStructureTest.Add("A meal");
            checkStructureTest.Add("Week 1");
            actualreturnAns = _menu.checkStructure(checkStructureTest);
            Assert.AreEqual(returnAns, actualreturnAns, "A day technically came after a week");
        }


        [Test]
        public void checkStructureTestFnMenu2()
        {
            //SetUp();
            int returnAns = 0, actualreturnAns;
            ArrayList checkStructureTest = new ArrayList();
            checkStructureTest.Add("Week 1");
            checkStructureTest.Add("Day 1");
            checkStructureTest.Add("A meal");
            checkStructureTest.Add("Week 1");
            actualreturnAns = _menu.checkStructure(checkStructureTest);
            Assert.AreEqual(returnAns, actualreturnAns, "Two different weeks are available .");
        }


        [Test]
        public void checkStructureTestFnMenu3()
        {
            //SetUp();
            int returnAns = 1, actualreturnAns;
            ArrayList checkStructureTest = new ArrayList();
            checkStructureTest.Add("Week 2");
            checkStructureTest.Add("Day 3");
            checkStructureTest.Add("A meal");
            actualreturnAns = _menu.checkStructure(checkStructureTest);
            Assert.AreEqual(returnAns, actualreturnAns, "It should have been the right choice.");
        }
        //****
        [Test]
        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "There was an unhandled null")]
        public void retriveMenuTestFnMenu1()
        {
            
            _menu.retriveMenu(null);
        }

        [Test]
        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Invalid menu name")]
        public void retriveMenuTestFnMenu2()
        {
            
            _menu.retriveMenu("Full Course");
        }

        [Test]
        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "There was an empty string")]
        public void retriveMenuTestFnMenu3()
        {
            
            _menu.retriveMenu("");
        }
        //****

        
    }
}


